package org.jeecg.modules.demo3.peijian.utill;

import com.puppycrawl.tools.checkstyle.checks.indentation.CatchHandler;
import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author wjn
 * @version V1.0
 * @date 2021/4/30 14:56
 * @Copyright © 2021/4/30 深圳卓翼航空无人机有限公司
 */
public class PdfData{
    public Map<String, Object> fileupload(String id){
        MultipartFile file = GetFile.multipartFile;
        System.out.println(file.getOriginalFilename());
        //首先要给文件找一个目录
        //先写返回值
        Map<String, Object> result = new HashMap<>();
        //保存文件路劲
        String realPath = "E:\\PDF\\fly\\axhk\\";
        //再是保存文件的文件夹
        File folder = new File(realPath);
        //如果不存在，就自己创建
        if(!folder.exists()){
            folder.mkdirs();
        }
        String newName =id + ".pdf";
        String path = realPath+newName;
        try {
            file.transferTo(new File(folder,newName));
            //如果指向成功了
            result.put("path",path);
        } catch (IOException e) {
            //返回异常
            e.printStackTrace();
        }
        return  result;
    }
}
